package com.yyuap.enterprise.impl;

import java.util.List;
import java.util.UUID;

import nc.bs.dao.BaseDAO;
import nc.bs.dao.DAOException;

import com.yyuap.enterprise.itf.IUser;
import com.yyuap.enterprise.vo.UserVO;

public class UserImpl implements IUser{

	@SuppressWarnings("unchecked")
	@Override
	public List<UserVO>  findUser(String condition) throws DAOException {
		// TODO 自动生成的方法存根
		BaseDAO dao = new BaseDAO();
		String strwhere = "";
		List<UserVO> users=null;
		if(condition!=null && !"".equals(condition)){
			strwhere = "name like '%" + condition + "%' or stuID like '%"+condition + "%'";
			users = (List<UserVO>) dao.retrieveByClause(UserVO.class, strwhere);
			
	
		}
		else{
			users=(List<UserVO>) dao.retrieveAll(UserVO.class);
		}
		
		return users.size()==0?null:users;
	}

	@Override
	public void deleteUser(UserVO user) throws DAOException {
		// TODO 自动生成的方法存根
		BaseDAO dao = new BaseDAO();
//		dao.deleteByPK(UserVO.class, id);
		dao.deleteVO(user);
		
	}

	@Override
	public String insertUser(UserVO user) throws DAOException {
		// TODO 自动生成的方法存根
		BaseDAO dao = new BaseDAO();
		return dao.insertVO(user);
	}

	@Override
	public int updateUser(UserVO user) throws DAOException {
		// TODO 自动生成的方法存根
		BaseDAO dao = new BaseDAO();
		int result = dao.updateVO(user);
		return result;
	}

	

}
